<?php
namespace app\common\model;
use think\Model;

/**
* BaseModel
*/
class BaseModel extends Model
{
	//tp5自带属性，自动赋值字段‘create_time’,'update_time'
	protected $autoWriteTimestamp = true;

    //tp5.07自带属性，格式化字段类型输出
	protected $type = [
        'create_time'     =>  'timestamp:Y-m-d h:i',
        'update_time'  =>  'timestamp:Y-m-d h:i',
        'start_time'     =>  'timestamp:Y-m-d h:i',
        'end_time'  =>  'timestamp:Y-m-d h:i',
    ];

	public function add($data){
		$data['status'] = 0;
		// $data['create_time'] = time();
		$this->save($data);

		return $this->id;
	}

	public function updateById($data, $id){
		return $this->allowField(true)->save($data,['id'=>$id]);
	}

}